package com.neuedu.web.servlet; /**
 * @auth 金山老师
 * title:   书籍代码
 * creatime: 2022-10-21 8:46
 * 描述 : ${dc}
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "CookieServlet", value = "/mycookie")
public class CookieServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // response.setHeader("Set-Cookie","///");

        // 如果没有session就创建一次，否则使用之前
        // HttpSession session = request.getSession();
        // System.out.println(session.getId());

        Cookie cookie = new Cookie("autoLogin","true");
        cookie.setMaxAge(1000);
        response.addCookie(cookie);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
